/*
 * @Author: 宋绍华
 * @Date: 2024-11-13 16:05:30
 * @LastEditors: wangshuixin 2412658453@qq.com
 * @LastEditTime: 2024-12-12 14:47:45
 * @FilePath: \sr_system_manager_ui\src\api\project\index.ts
 * @Description: 我的项目
 */
import request from '@/utils/request'
import {
  ProjectChangeDetailDTO,
  ProjectChangeDetailVO,
  ProjectChangeApproveDTO,
  BaseSuccessRespDTO,
  ProjectApproveApproveDTO,
  ProjectApproveRejectDTO,
  ProjectDocumentCreateDTO,
  BaseIdReqDTO,
  ProjectBaseDTO,
  ProjectDocumentDetailVO,
  ProjectChangeMemberUpdateDTO,
  ProjectChangeRespDTO,
  DictionaryListRespVO,
  ProjectSubmitDTO,
  ProjectNoticeQuery,
  PageBeanProjectNoticePageVO,
  ProjectMemberCreateDTO,
  ProjectCooperativeUnitsCreateDTO,
  ProjectFundingCreateDTO,
  ProjectBaseDetailVO,
  ProjectMemberDetailVO,
  ProjectCooperativeUnitsVO,
  ProjectFundingDetailVO,
  OperationPageReqDTO,
  OperationPageRespVO,
  ProjectNoticePageVO,
  ProjectWarmingBaseCreateDTO,
  ProjectNoticeCreateDTO,
  ProjectNoticeDetailVO,
  ProjectMaterialDetailVO,
  ProjectWarmingBaseDetailVO,
} from './types'
import { ProjectBaseCreateDTO } from '@/types/project/request'
import { PageBeanProjectBasePageVO , ProjectBasePageVO} from '@/types/project/response'
import { PaginationQueryUniteRespDTO } from '@/types'

// 查询参数详细
export function getProjectPageApi(data) {
  return request<PageBeanProjectBasePageVO>({
    url: `/project/api/base/page`,
    method: 'post',
    data
  })
}

// 列表查询
export function getProjectListApi(data) {
  return request<ProjectBasePageVO[]>({
    url: `/project/api/base/list`,
    method: 'post',
    data
  })
}

// 删除 
export const projectDeleteApi = (data: BaseIdReqDTO) => {
  return request<BaseSuccessRespDTO>({
    url: `/project/api/base/delete`,
    method: 'post',
    data
  })
}

// 变更详情
export const projectChangeDetailApi = (data: ProjectChangeDetailDTO) => {
  return request<ProjectChangeDetailVO>({
    url: `/project/api/change/detail`,
    method: 'post',
    data
  })
}

// 变更审核通过
export const projectChangeApproveApi = (data: ProjectChangeApproveDTO) => {
  return request<BaseSuccessRespDTO>({
    url: `/project/api/change/approve`,
    method: 'post',
    data
  })
}

// 变更审核驳回
export const projectChangeRejectApi = (data: ProjectChangeApproveDTO) => {
  return request<BaseSuccessRespDTO>({
    url: `/project/api/change/reject`,
    method: 'post',
    data
  })
}

// 审核通过
export const projectApproveApproveApi = (data: ProjectApproveApproveDTO) => {
  return request<BaseSuccessRespDTO>({
    url: `/project/api/approve/approve`,
    method: 'post',
    data
  })
}

// 审核驳回
export const projectApproveRejectApi = (data: ProjectApproveRejectDTO) => {
  return request<BaseSuccessRespDTO>({
    url: `/project/api/approve/reject`,
    method: 'post',
    data
  })
}

// 结项不通过
export const projectApproveFailedApi = (data: ProjectApproveRejectDTO) => {
  return request<BaseSuccessRespDTO>({
    url: `/project/api/approve/approveFailed`,
    method: 'post',
    data
  })
}


// 项目文档
export const projectDocumentListDetailApi = (data: ProjectBaseDTO) => {
  return request<ProjectDocumentDetailVO[]>({
    url: `/project/api/document/detail`,
    method: 'post',
    data
  })
}

// 项目文档创建
export const projectDocumentCreateApi = (data: ProjectDocumentCreateDTO) => {
  return request<BaseSuccessRespDTO>({
    url: `/project/api/document/create`,
    method: 'post',
    data
  })
}

// 项目文档删除
export const projectDocumentDeleteApi = (data: BaseIdReqDTO) => {
  return request<BaseSuccessRespDTO>({
    url: `/project/api/document/delete`,
    method: 'post',
    data
  })
}

// 人员替换创建、更新
export const projectChangeMemberUpdateApi = (data: ProjectChangeMemberUpdateDTO) => {
  return request<ProjectChangeRespDTO>({
    url: `/project/api/change/createOrUpdateMember`,
    method: 'post',
    data
  })
}

// // 项目延期创建、更新
// export const projectCreateOrUpdateDelayApi = (data: ProjectChangeDelayUpdateDTO) => {
//   return request<ProjectChangeRespDTO>({
//     url: `/project/api/change/createOrUpdateDelay`,
//     method: 'post',
//     data
//   })
// }

// // 项目经费变更创建、更新
// export const projectCreateOrUpdateFundingApi = (data: ProjectChangeFundingUpdateDTO) => {
//   return request<ProjectChangeRespDTO>({
//     url: `/project/api/change/createOrUpdateFunding`,
//     method: 'post',
//     data
//   })
// }



// // 项目终止/其他变更创建、更新
// export const projectCreateOrUpdateStopApi = (data: ProjectChangeUpdateDTO) => {
//   return request<ProjectChangeRespDTO>({
//     url: `/project/api/change/createOrUpdateStop`,
//     method: 'post',
//     data
//   })
// }

// 我的项目-创建
export const createProjectApi = (data: ProjectBaseCreateDTO) => {
  return request<BaseSuccessRespDTO>({
    url: `/project/api/base/create`,
    method: 'post',
    data
  })
}

// 我的项目-更新
export const updateProjectApi = (data: ProjectBaseCreateDTO) => {
  return request<BaseSuccessRespDTO>({
    url: `/project/api/base/update`,
    method: 'post',
    data
  })
}

// 我的项目提交
export const projectApproveSubmitApi = (data: ProjectSubmitDTO) => {
  return request<BaseSuccessRespDTO>({
    url: `/project/api/approve/submit`,
    method: 'post',
    data
  })
}


// 我的项目-获取相关字典
export const getDicListApi = (data: { code?: string[], dictionaryId?: number[] }) => {
  return request<DictionaryListRespVO[]>({
    url: `/base/api/dictionary/list`,
    method: 'post',
    data
  })
}

// 项目通知分页查询
export const getNoticePageApi = (data: ProjectNoticeQuery) => {
  return request<PageBeanProjectNoticePageVO>({
    url: `/project/api/notice/page`,
    method: 'post',
    data
  })
}

// 我的项目-创建成员
export const projectMemberCreateApi = (data: ProjectMemberCreateDTO) => {
  return request<BaseSuccessRespDTO>({
    url: `/project/api/member/update`,
    method: 'post',
    data
  })
}

// 我的项目-获取成员详情
export const getProjectMemberApi = (data: { projectId: string }) => {
  return request<ProjectMemberDetailVO[]>({
    url: `/project/api/member/detail`,
    method: 'post',
    data
  })
}

// 我的项目-合作单位
export const CooperativeCreateApi = (data: ProjectCooperativeUnitsCreateDTO) => {
  return request<BaseSuccessRespDTO>({
    url: `/project/api/cooperativeUnits/update`,
    method: 'post',
    data
  })
}

// 我的项目-预算信息
export const FundingCreateApi = (data: ProjectFundingCreateDTO) => {
  return request<BaseSuccessRespDTO>({
    url: `/project/api/funding/update`,
    method: 'post',
    data
  })
}


// 我的项目-项目文档
export const DocCreateApi = (data: { fileIds: number[], isTemp: boolean, projectId: string }) => {
  return request<BaseSuccessRespDTO>({
    url: `/project/api/document/create`,
    method: 'post',
    data
  })
}

// 我的项目-项目文档
export const DocUpdateApi = (data: { fileIds: number[], isTemp: boolean, projectId: string }) => {
  return request<BaseSuccessRespDTO>({
    url: `/project/api/document/update`,
    method: 'post',
    data
  })
}


// 我的项目-基本信息
export const getBaseDetailsApi = (data: { id: string }) => {
  return request<ProjectBaseDetailVO>({
    url: `/project/api/base/detail`,
    method: 'post',
    data
  })
}

// 我的项目-获取合作信息
export const getCoopDetailsApi = (data: { id: string }) => {
  return request<ProjectCooperativeUnitsVO[]>({
    url: `/project/api/cooperativeUnits/detail`,
    method: 'post',
    data
  })
}

// 我的项目-获取预算信息
export const getFundingDetailsApi = (data: { id: string }) => {
  return request<ProjectFundingDetailVO[]>({
    url: `/project/api/funding/detail`,
    method: 'post',
    data
  })
}
// 我的项目-操作日志
export const getRecordPageApi = (data: OperationPageReqDTO) => {
  return request<PaginationQueryUniteRespDTO<OperationPageRespVO>>({
    url: `/base/api/operation/log/page`,
    method: 'post',
    data
  })
}

// 我的项目-获取项目通知列表
export const getProjectNoticePageApi = (data: ProjectNoticeQuery) => {
  return request<PaginationQueryUniteRespDTO<ProjectNoticePageVO>>({
    url: `/project/api/notice/page`,
    method: 'post',
    data
  })
}

// 我的项目-发起中检
export const submitApproveInitiateApi = (data: { projectIds: string[], type: number }) => {
  return request<BaseSuccessRespDTO>({
    url: `/project/api/approve/initiate`,
    method: 'post',
    data
  })
}

// 我的项目-项目预警设置
export const warningBaseCreateApi = (data: ProjectWarmingBaseCreateDTO) => {
  return request<BaseSuccessRespDTO>({
    url: `/project/api/warmingBase/create`,
    method: 'post',
    data
  })
}

// 我的项目-项目预警设置
export const warningBaseUpdateApi = (data: ProjectWarmingBaseCreateDTO) => {
  return request<BaseSuccessRespDTO>({
    url: `/project/api/warmingBase/update`,
    method: 'post',
    data
  })
}

// 我的项目-删除通知
export const deleteBaseCreateApi = (data: { id: string }) => {
  return request<BaseSuccessRespDTO>({
    url: `/project/api/notice/delete`,
    method: 'post',
    data
  })
}


// 我的项目-新建通知
export const projectCreateNoticesApi = (data: ProjectNoticeCreateDTO) => {
  return request<BaseSuccessRespDTO>({
    url: `/project/api/notice/create`,
    method: 'post',
    data
  })
}

// 我的项目-更新通知
export const projectUpdateNoticesApi = (data: ProjectNoticeCreateDTO) => {
  return request<BaseSuccessRespDTO>({
    url: `/project/api/notice/update`,
    method: 'post',
    data
  })
}

// 我的项目-消息通知详情
export const getProjectNoticesDetailsApi = (data: { id: string }) => {
  return request<ProjectNoticeDetailVO>({
    url: `/project/api/notice/detail`,
    method: 'post',
    data
  })
}

// 我的项目-获取材料详情
export const getApproveMaterialDetailsApi = (data: { materialType: number, projectId: string }) => {
  return request<ProjectMaterialDetailVO>({
    url: `/project/api/approve/materialDetail`,
    method: 'post',
    data
  })
}

// 我的项目-获取预警详情
export const getAlertDetailApi = (data: { projectNature: number }) => {
  return request<ProjectWarmingBaseDetailVO>({
    url: `/project/api/warmingBase/detail`,
    method: 'post',
    data
  })
}

/**
 * 导出 项目列表
*/
export function exportProjectListApi(params: { projectNature?: number, idList?: string[] }) {
  return request({
    url: `/project/api/base/export`,
    method: 'post',
    responseType: 'blob',
    data: params
  })
}

/**
 * 导出 项目详情
*/
export function exportProjectDetailApi(params: { id?: string }) {
  return request({
    url: `/project/api/base/exportDetail`,
    method: 'post',
    responseType: 'blob',
    data: params
  })
}